<!--#include file="conn.asp"-->
<!--#include file="chkuser.asp"-->
<%
call adminRight(5)

ID=request("ID")
AllID=request("chk")
curpage=request("curpage")

if request("action")="Del" then
	sql="Delete from Message where ID="&ID
	conn.execute(sql)
	Go("?showMsgStr=<br><b>留言信息已删除成功！</b>|parent|3000|500||")
end if

if request("action")="delall" then
	If AllID="" Then Alert("没有选择数据"):GoBack():response.End()
	sql="delete from Message where ID in("&AllID&")"
	conn.execute(sql)
	Go("?showMsgStr=<br><b>留言信息已批量删除成功！</b>|parent|3000|500||")
end if

if trim(request("action"))="editreply" then
	show=trim(request("show"))
	if show="" then show=False
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from Message where ID="&ID
	rs.open sql,conn,1,3
	rs("name")=trim(request("name"))
	rs("tel")=trim(request("tel"))
	rs("email")=trim(request("email"))
	rs("qq")=trim(request("qq"))
	rs("title")=trim(request("title"))
	rs("content")=replace(trim(request("content")),"="&chr(34)&"./../","="&chr(34)&"./")
	rs("reply")=replace(trim(request("reply")),"="&chr(34)&"./../","="&chr(34)&"./")
	rs("show")=show
	rs.update
	rs.close
	set rs=nothing
	alert("保存成功!")
	Go("?curpage="&curpage&"&showMsgStr=<br><b>留言信息已保存成功！</b>|parent|3000|500||")
end if
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>留言管理</title>
<link href="style.css" rel="stylesheet" type="text/css" />

<script language="javascript" type="text/javascript">
function selcheck(id) {
   var e =document.getElementById(id);
   var objs = e.getElementsByTagName("input");
   if (e.checked){
      e.checked = false;
      for(var i=0; i<objs.length; i++) {
         if(objs[i].type.toLowerCase() == "checkbox" )
         objs[i].checked = false;
      }
   }   else   {
      e.checked = true;
      for(var i=0; i<objs.length; i++) {
         if(objs[i].type.toLowerCase() == "checkbox" )
         objs[i].checked = true;
      }
   }
}
</script>
<script type="text/javascript" charset="utf-8" src="./../kindeditor/kindeditor.js"></script>
</head>
<body>
    <div id="frame_Toolbar" class="toolbarBg"> 
		<a href="javascript:self.history.back();" class="icoBtn_ct"><span class="btnIco btnBack"></span>返回</a> 
		<a href="javascript:self.location.reload();" class="icoBtn_ct"><span class="btnIco btnReload"></span>刷新</a> 
		<span class="split ftSplit" ></span>
	    <div id="guide">点击<span class="light_orange"> 详细信息 </span>查看详细信息</div>
		<%
			   Set rs = Server.CreateObject("ADODB.Recordset")
			   sql="select * from Message order by id desc"
			   rs.open sql,conn,1,1
	    %>
	    <div class="pageInfo right light_gray">[当前共有<span id="Label_total_top" class="light_bOrange"><%=rs.recordcount%></span>条记录]</div>
    </div>
	<div id="MainContent">
	<%if request("ID")="" then%>
	<form method="POST" id=formdel name="formdel" action="">
     <table class="cTable table tCenter">
	    <tr class="cTitle toolbarBg">
		    <td width="7%"><span class="checkbox"><input type="checkbox" name="chkall" onClick="selcheck('MainContent')" /></span></td>
		    <td width="10%"><span class="split ctSplit"></span><div>编号</div></td>
		    <td width="12%"><span class="split ctSplit"></span><div>用户名</div></td>
		    <td width="26%"><span class="split ctSplit"></span><div>留言主题</div></td>
		    <td width="17%"><span class="split ctSplit"></span><div>留言日期</div></td>
			<td width="13%"><span class="split ctSplit"></span><div>是否已审核</div></td>
			<td width="15%"><span class="split ctSplit"></span><div>编辑</div></td>
	    </tr>
			<%
			   rs.pagesize=14
			   curpage=clng(Request.QueryString("curpage"))
			   if curpage<=0 then curpage=1
			   if curpage>rs.pagecount then curpage=rs.pagecount
			   if not rs.eof then rs.absolutepage=curpage
			   for i=1 to rs.pagesize
			   if rs.eof then
			   exit for
			   end if
		 %>
		<tr class="trDataList" onMouseOver="this.className='trDataListHover'" onMouseOut="this.className='trDataList'">
			<td><input type="checkbox" name="chk" value="<%=rs("ID")%>" /></td>
			<td><%=rs("ID")%></td>
			<td><%=rs("Name")%></td>
			<td><%=gotTopic(rs("title"),23)%></td>
			<td><%=rs("AddDate")%></td>
		    <td><%
			if rs("Show")=true then
			response.Write("已审核")
			else
			response.Write("<font color=red>未审核</font>")
			end if
			%></td>
			<td width="15%"><a href="?ID=<%=rs("id")%>&curpage=<%=curpage%>">详细信息</a>/<a href="?ID=<%=rs("ID")%>&action=Del" onClick="return confirm('确定删除？')">删除</a></td>
		</tr>
		<%
			rs.movenext
			next
        %>	
	</table> 
    <div id="cEndToolbar" class="toolbarBg">
        <div class="pageList">
				<%
				set pageObj=new pager
				response.Write pageObj.link(rs.recordcount,rs.pagesize,curpage,"?curpage=",qryString)
				%>
		<%
			rs.close
			Set rs=nothing
		 %>
	    </div>
	    <div class="pageSelect"><span class="iptSl"><input type="checkbox" name="chkall" onClick="selcheck('MainContent')" /></span><a href="javascript:selcheck('MainContent');"><span class="btnTxt">选择</span></a></div>
	    <span class="split cpSplit" ></span>
	    <div class="pageBtnDo">
	        <div class="icoBtn_do"><input type="image" name="Delete_Button" id="Delete_Button" class="btnIco btnDel" src="images/Empty.gif" onClick="document.formdel.action='?action=delall';return confirm('确定要删除吗?');" style="border-width:0px;" /></div>
	    </div>
	</div>	
    
	</form>
	
	
<%else%>	

<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from Message where id="&ID
rs.open sql,conn,1,1
%>
<form method="POST" id=formreply name="formreply" action="?action=editreply&ID=<%=ID%>&curpage=<%=curpage%>">
<table class="cTable table">
	<tr class="cTitle toolbarBg">
	 <td colspan="2"><div class="cLeftPadding">留言详细内容</div></td>
	</tr>
  <tr>
    <td width="20%" align="right">姓名：</td>
    <td align="left"><input type="text"  size="35" name="name" value="<%=rs("name")%>" style="width:300px;" /></td>
  </tr>
  <tr>
    <td align="right">电话：</td>
    <td align="left"><input type="text"  name="tel" size="35" value="<%=rs("tel")%>" style="width:300px;" /></td>
  </tr>
  <tr>
    <td align="right">E-mail：</td>
    <td align="left"><input type="text" name="email" size="35" value="<%=rs("email")%>" style="width:300px;" /></td>
  </tr>
  <tr>
    <td align="right">QQ：</td>
    <td align="left"><input type="text"  name="qq" size="35" value="<%=rs("qq")%>" style="width:300px;" /></td>
  </tr>
  <tr>
    <td align="right">主题：</td>
    <td align="left"><input type="text" name="title" size="35" value="<%=rs("title")%>" style="width:300px;" /></td>
  </tr>
  <tr>
    <td align="right">留言内容：</td>
    <td align="left"><script type="text/javascript">
		KE.show({
			id : 'content',
			resizeMode : 1,
			items : [
			'source', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
			'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', 'link', 'unlink', 'emoticons'],
			afterCreate : function(id) {
				KE.blur(id);
			}
		});
	    </script>
		<div class="editor">
		<textarea id="content" name="content" style="width:450px;height:160px;visibility:hidden;"><%=replace(rs("content")&"","="&chr(34)&"./","="&chr(34)&"./../")%></textarea>
		</div></td>
  </tr>
  <tr>
    <td align="right">回复：</td>
    <td align="left"><script type="text/javascript">
		KE.show({
			id : 'reply',
			resizeMode : 1,
			items : [
			'source', 'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
			'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', 'link', 'unlink', 'emoticons'],
			afterCreate : function(id) {
				KE.blur(id);
			}
		});
	    </script>
		<div class="editor">
		<textarea id="reply" name="reply" style="width:450px;height:160px;visibility:hidden;"><%=replace(rs("reply")&"","="&chr(34)&"./","="&chr(34)&"./../")%></textarea>
		</div></td>
  </tr>
  <tr>
    <td align="right">审核并前台显示：</td>
    <td align="left"><input type="checkbox" name="show" <%if rs("show")=True then response.Write("checked")%> value="True" ></td>
  </tr>
</table>
    <div id="cEndToolbar" class="toolbarBg">
      <div class="caButCase">
			<input name="btnSavePx" value="保 存" type="submit" class="button"/>
			<input name="btnExitPx" value="返 回" type="button" onClick="history.back()" class="button"/> 
      </div>
    </div>
</form>
<%
rs.close
set rs=nothing
%>
<%end if%>
</div>
<script language="javascript">
    function isnum()
    {
        if(event.keyCode<45 || event.keyCode>57)
        {
            event.keyCode=0;
        }
    }                             
</script>
</body>
</html>